(function(win,doc){
    function change(){
        doc.documentElement.style.fontSize=doc.documentElement.clientWidth/375*23.4375+'px';
    }
    change();
    win.addEventListener('resize',change,false);
})(window,document);
$(function(){
    //发送验证码
    function countdown(v) {
        $(".num").text(v);
        var now=v-1;
        if(parseInt(v) >0){
            dingshi=setTimeout(function () {
                countdown(now);
            }, 1000);
        }else{
            clearTimeout(dingshi);
            $(".reset1").hide();
            $(".send").show();
        }
    }

    //发送验证码
    $(".send").click(function(){
        var value=$("input[name='phone']").val();

        if (!value) {
            common.showMsgBox('请先填写手机号');
            return;
        }
        reg=/^1[3|4|5|7|8][0-9]\d{8}$/;
        if(!reg.test(value)) {
            common.showMsgBox('手机号格式不正确');
        } else {
            $(".reset1").show();
            $(".send").hide();
            var num = $(".num").html();
            setTimeout(countdown(num),1000);
            phone = $("input[name='phone']").val();
            re = common.post('zyxh', 'checkCode', {phone : phone});
            console.log(re);
        }
    });

    //提交申请
    $("#getMoney").click(function(){
        bankName = $("input[name='bankName']").val();
        bankOpenAddr = $("input[name='bankOpenAddr']").val();
        bankAccountId = $("input[name='bankAccountId']").val();
        bankAccountName = $("input[name='bankAccountName']").val();
        phone = $("input[name='phone']").val();
        phone_checkCode = $("input[name='phone_checkCode']").val();

        if (!bankName || !bankOpenAddr || !bankAccountId || !bankAccountName || !phone || !phone_checkCode) {
            common.showMsgBox('请填写完整');
            return;
        }

        param = {
            bankName : bankName,
            bankOpenAddr : bankOpenAddr,
            bankAccountId : bankAccountId,
            bankAccountName : bankAccountName,
            phone : phone,
            phone_checkCode : phone_checkCode
        };
        console.log('提交参数：');
        console.log(param);
        re = common.post('zyxh', 'getMoney_post', param);
        if (re.result == 0) {
            alert('提交成功');
            location.reload();
        } else {
            common.showMsgBox(re.message);
        }
    });
});
